/* 
 * Gneat (http://gneat.org)
 *
 * (C) Copyright 2011 and beyond - Claudio Stella, all rights reserved.
 *
 * This file is part of Gneat.
 *
 * Gneat is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License (LGPL)
 * as published by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Gneat is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * and the GNU General Public License, for completeness, along with Gneat.  
 * If not, see <http://www.gnu.org/licenses/>.
 */
package org.neatshell.gneat.client.presenter.core.traversing;

import org.neatshell.gneat.client.presenter.core.IPresenter;
import org.neatshell.gneat.client.presenter.core.IPresenterList;

public interface TreeTraversal {
	/**
	 * Get the Presenter referencing the <b>index-th</b> child NODE of this presenter's underlying ELEMENT,
	 * filtered by a NODE type.
	 * @param index the index of the referenced child NODE.
	 * @param nodeType the desired type of NODE, <b>1</b>=ELEMENT, <b>3</b>=TEXT, <b>8</b>=COMMENT, <b>null</b> means any type.
	 * @return an instance of {@link Presenter} if the <b>index-th</b> child NODE <b>exists</b>, a reference to {@link PresenterNull} if <b>not</b>.
	 */
	IPresenter child(Integer index, Integer nodeType);

	/**
	 * Get the Presenter referencing the <b>index-th</b> child ELEMENT of this presenter's underlying ELEMENT.
	 * @param index the index of the referenced child ELEMENT.
	 * @return an instance of {@link Presenter} if the <b>index-th</b> child ELEMENT <b>exists</b>, a reference to {@link PresenterNull} if <b>not</b>.
	 */
	IPresenter child(Integer index);

	/**
	 * Get a PresenterList containing the Presenter objects referencing the <b>children</b>, of type ELEMENT, of this presenter's underlying ELEMENT.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */
	IPresenterList children();

	/**
	 * Get a PresenterList containing the Presenter objects referencing the <b>children</b>, of this presenter's underlying ELEMENT,
	 * filtered by a NODE type.
	 * @param nodeType the desired type of NODEs, <b>1</b>=ELEMENT, <b>3</b>=TEXT, <b>8</b>=COMMENT, <b>null</b> means any type.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */
	IPresenterList children(Integer nodeType);


	/**
	 * Get the Presenter referencing the <b>index-th</b> child NODE of type TEXT or COMMENT, of this presenter's underlying ELEMENT.
	 * @param index the index of the referenced child NODE.
	 * @return an instance of {@link Presenter} if the <b>index-th</b> child NODE <b>exists</b>, a reference to {@link PresenterNull} if <b>not</b>.
	 */
	IPresenter content(Integer index);
	
	/**
	 * Get a PresenterList containing the Presenter objects referencing the <b>children</b>, of type TEXT or COMMENT, of this presenter's underlying ELEMENT.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */
	IPresenterList contents();
	
	/**
	 * Get a PresenterList containing the Presenter objects referencing the <b>descendants</b>, of type ELEMENT, of this presenter's underlying ELEMENT.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */
	IPresenterList find();
	
	/**
	 * Get a PresenterList containing the Presenter objects referencing the <b>descenants</b>, of this presenter's underlying ELEMENT,
	 * filtered by a NODE type.
	 * @param nodeType the desired type of NODEs, <b>1</b>=ELEMENT, <b>3</b>=TEXT, <b>8</b>=COMMENT, <b>null</b> means any type.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */
	IPresenterList find(Integer nodeType);

	/**
	 * Get the Presenter referencing the immediately <b>following</b> sibling ELEMENT of this presenter's underlying NODE.
	 * @return an instance of {@link Presenter} if a following sibling ELEMENT <b>exists</b>, a reference to {@link PresenterNull} if <b>not</b>.
	 */
	IPresenter next();

	/**
	 * Get the Presenter referencing the immediately <b>following</b> sibling NODE of this presenter's underlying NODE,
	 * filtered by a NODE type.
	 * @param nodeType the desired type of NODE, <b>1</b>=ELEMENT, <b>3</b>=TEXT, <b>8</b>=COMMENT, <b>null</b> means any type.
	 * @return an instance of {@link Presenter} if a following sibling NODE, <b>exists</b>, a reference to {@link PresenterNull} if <b>not</b>.
	 */
	IPresenter next(Integer nodeType);

	/**
	 * Get a PresenterList containing the Presenter objects referencing the <b>following</b> siblings, of type ELEMENT, of this presenter's underlying NODE.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */
	IPresenterList nextAll();

	/**
	 * Get a PresenterList containing the Presenter objects referencing the <b>following</b> siblings, of this presenter's underlying NODE,
	 * filtered by a node type.
	 * @param nodeType the desired type of NODEs, <b>1</b>=ELEMENT, <b>3</b>=TEXT, <b>8</b>=COMMENT, <b>null</b> means any type.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */	
	IPresenterList nextAll(Integer nodeType);
	
	/**
	 * Get a PresenterList containing the Presenter objects referencing the <b>following</b> siblings, of type ELEMENT, of this presenter's underlying NODE,
	 * up to but not including the NODE underlaid by the passed Presenter.
	 * @param until the Presenter underlying the stopping NODE, note that the node type is indifferent.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */
	IPresenterList nextUntil(IPresenter until);

	/**
	 * Get a PresenterList containing the Presenter objects referencing the <b>following</b> siblings, of type ELEMENT, of this presenter's underlying NODE,
	 * up to but not including the NODE underlaid by the passed Presenter, filtered by a node type.
	 * @param until the Presenter underlying the stopping NODE, note that the node type is indifferent.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */	
	IPresenterList nextUntil(IPresenter until, Integer nodeType);

	/**
	 * Get the Presenter referencing the <b>parent</b> ELEMENT of this presenter's underlying NODE.
	 * @return an instance of {@link Presenter} if the parent ELEMENT <b>exists</b>, a reference to {@link PresenterNull} if <b>not</b>.
	 */
	IPresenter parent();
	
	/**
	 * Get a PresenterList containing the Presenter objects referencing the <b>ancestors</b> of this presenter's underlying ELEMENT.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */
	IPresenterList parents();
	
	/**
	 * Get a PresenterList containing the Presenter objects referencing the <b>ancestors</b> of this presenter's underlying ELEMENT,
	 * up to but not including the ELEMENT underlaid by the passed Presenter.
	 * @param until the Presenter underlying the stopping ELEMENT.
	 * @return an instance of {@link PresenterList}, even with no item.	 
	 */
	IPresenterList parentsUntil(IPresenter until);

	/**
	 * Get the Presenter referencing the immediately <b>preceding</b> sibling ELEMENT of this presenter's underlying NODE.
	 * @return an instance of {@link Presenter} if a preceding sibling ELEMENT <b>exists</b>, a reference to {@link PresenterNull} if <b>not</b>.
	 */
	IPresenter prev();

	/**
	 * Get the Presenter referencing the immediately <b>preceding</b> sibling NODE of this presenter's underlying NODE,
	 * filtered by a node type.
	 * @param nodeType the desired type of NODE, <b>1</b>=ELEMENT, <b>3</b>=TEXT, <b>8</b>=COMMENT, <b>null</b> means any type.
	 * @return an instance of {@link Presenter} if a preceding sibling NODE, <b>exists</b>, a reference to {@link PresenterNull} if <b>not</b>.
	 */
	IPresenter prev(Integer nodeType);

	/**
	 * Get a PresenterList containing the Presenter objects referencing the <b>preceding</b> siblings, of type ELEMENT, of this presenter's underlying NODE.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */
	IPresenterList prevAll();

	/**
	 * Get a PresenterList containing the Presenter objects referencing the <b>preceding</b> siblings, of this presenter's underlying NODE,
	 * filtered by a node type.
	 * @param nodeType the desired type of NODEs, <b>1</b>=ELEMENT, <b>3</b>=TEXT, <b>8</b>=COMMENT, <b>null</b> means any type.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */
	IPresenterList prevAll(Integer nodeType);

	/**
	 * Get a PresenterList containing the Presenter objects referencing the <b>preceding</b> siblings, of type ELEMENT, of this presenter's underlying NODE,
	 * up to but not including the NODE underlaid by the passed Presenter.
	 * @param until the Presenter underlying the stopping NODE, note that the node type is indifferent.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */
	IPresenterList prevUntil(IPresenter until);
	
	/**
	 * Get a PresenterList containing the Presenter objects referencing the <b>preceding</b> siblings, of this presenter's underlying NODE,
	 * up to but not including the NODE underlaid by the passed Presenter, filtered by a node type.
	 * @param until the Presenter underlying the stopping NODE, note that the node type is indifferent.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */
	IPresenterList prevUntil(IPresenter until, Integer nodeType);

	/**
	 * Get a PresenterList containing the Presenter objects referencing <b>all</b> the siblings, of type ELEMENT, of this presenter's underlying NODE.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */
	IPresenterList siblings();
	
	/**
	 * Get a PresenterList containing the Presenter objects referencing <b>all</b> the siblings, of this presenter's underlying NODE,
	 * filtered by a node type.
	 * @param nodeType the desired type of NODEs, <b>1</b>=ELEMENT, <b>3</b>=TEXT, <b>8</b>=COMMENT, <b>null</b> means any type.
	 * @return an instance of {@link PresenterList}, even with no item.
	 */
	IPresenterList siblings(Integer nodeType);
}